using System;
using System.IO;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using Jungle.Code.DAL;
using Jungle.Code.BLL;
using Jungle.Code.Utils;
using Jungle.Code.Core;

using System.Data.SqlClient;
using System.Data.SqlTypes;

public partial class User : BaseUserModule
{
    public string flink;
    public string url;

    protected string GetLinkFromDatabase(string ConnectString,string secid_)
    {
        string ret="";
        
        SqlConnection Connect = new SqlConnection(ConnectString);
        try
        {
            SqlDataReader reader = null;
            SqlCommand command = new SqlCommand();
            command.Connection = Connect;
            command.CommandType = CommandType.Text;
            command.CommandText = "declare @r varchar(50) ; declare @url varchar(200) ; exec dbo.GetBannerFileLink " + secid_ + ",@r output,@url output;select @r as r,@url as url;";

            Connect.Open();
            reader = command.ExecuteReader();
          
            while (reader.Read())
            {
                if (!reader.IsDBNull(0)) flink = (string)reader["r"];
                  if (!reader.IsDBNull(1)) url = (string)reader["url"];
                         
            }
            reader.Close();
            Connect.Close();
          }
                
        catch (SqlException ex)
        {
           Response.Write(ex.ToString());
        }
        finally
        {
           Connect.Close();
        }
        return ret;
    }
    //-----------------------------------------------------
    protected void Page_Load(object sender, EventArgs e)
    {
        string ConnectString = DBHelper.ConnectionString;

        string secid_ = base.section.SectionID.ToString();

        string err = GetLinkFromDatabase(ConnectString, secid_);

        Image1.ImageUrl = "~/Modules/Banners/UploadsBanners/"+Path.GetFileName(flink);
       
       // Label1.Text =  Path.GetFileName(url);


    }
}
